$.getScript("targetsConnect/public.js",function(){
	sendConnectAjax("#connectTabletime_select",createConnectlist);
}); 

$("#connectTablesubmit").click(function(){
	$("#example_wrapper").remove();
	sendConnectAjax("#connectTabletime_select",createConnectlist);
});

function createConnectlist(xml_data){
	var data = {};
	data.title = [];
	data.rows = [];
	$(xml_data).find("fieldmap").children().each(function(i){
		var label = $(this).get(0).attributes.getNamedItem("name").nodeValue;
		data.title.push(label);
	});
	$(xml_data).find("datas").children().each(function(i){
		var x=$(this).get(0).attributes.length;
		var list = [];
			for(var j=1;j<=x;j++){
			 	var label = $(this).get(0).attributes.getNamedItem('col'+j).nodeValue;
			 	if(j==x){
			 		label=parseFloat(label)*100;
			 		if(label.toString().split('.')[1])
			 			label=label.toFixed(2)+'%';
			 		else
			 			label=label+'%';
				}
				list.push(label);
	  		}
	  		data.rows.push(list);
	});
	TABLETOOLS.createTable(data,"#Connecta_info","100%","100",[1,2,3,4],"connectTable");
}
